import $web3js from "../web3.js";

const ifil721Contract = require("./ifil721Contract.json");

let contractAddress = "";
let web3 = $web3js.getWeb3();
let contractConst = {
  contract: web3
    ? new web3.eth.Contract(ifil721Contract.abi, contractAddress)
    : ""
};
const getIfil721Address = () => {
  return contractAddress;
};

const getIfil721Contract = () => {
  return contractConst.contract;
};

const get712IsApprovedForAll = (owner, operator) => {
  return $web3js.commonCall(
    getIfil721Contract().methods.isApprovedForAll,
    owner,
    operator
  );
};

const setApprovalForAll = (operator, _approved) => {
  return $web3js.commonSend(
    getIfil721Contract().methods.setApprovalForAll,
    operator,
    _approved
  );
};

const setApprovalForAllEstimateGas = (operator, _approved) => {
  return $web3js.commonEstimateGas(
    getIfil721Contract().methods.setApprovalForAll,
    operator,
    _approved
  );
};

export default {
  getIfil721Address,
  getIfil721Contract,
  get712IsApprovedForAll,
  setApprovalForAll,
  setApprovalForAllEstimateGas
};
